import hashlib
import time
import random

import frida
import sys


# Application(identifier="today.tophub.app", name="今日热榜", pid=15873, parameters={})
rdev = frida.get_remote_device()
# rdev = frida.get_usb_device()
session = rdev.attach("今日热榜")


# today.tophub.app.utils.j
scr = '''
Java.perform(function () {
    var j = Java.use('today.tophub.app.utils.j$a'); // 替换为实际的类路径
    j.a.implementation = function (str){
        console.log('调用原始函数 a()，参数为: ' + str);
        var result = this.a(str); // 调用原始函数
        console.log('返回值为: ' + result);
        return result;
    };
    j.c.implementation = function (bArr) {
        console.log('调用原始函数 c()，参数为: ' + bArr);
        var result = this.c(bArr); // 调用原始函数
        console.log('返回值为: ' + result);
        return result;
        console.log(Java.use("android.util.Log").getStackTraceString(Java.use("java.lang.Throwable").$new()));
    };
});
'''

script = session.create_script(scr)


def on_message(message, data):
    print(message, data)


script.on("message", on_message)

script.load()
sys.stdin.read()


